package cn.cvs.service.storageRecord;

import cn.cvs.pojo.StorageRecord;
import org.apache.log4j.Logger;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import java.util.Date;

public class StorageRecordTest {
    private Logger logger=Logger.getLogger(StorageRecordTest.class);

    @Test
    public void testAdd() {
        ApplicationContext context=new ClassPathXmlApplicationContext("applicationContext.xml");
        StorageRecordService storageRecordService = context.getBean(StorageRecordService.class);
        StorageRecord storageRecord=new StorageRecord();
        storageRecord.setId(19);
        storageRecord.setSrCode("sr_2019_022");
        storageRecord.setGoodsName("雪碧");
        storageRecord.setGoodsDesc("饮料");
        storageRecord.setGoodsUnit("瓶");
        storageRecord.setGoodsCount(1500.00);
        storageRecord.setTotalAmount(4500.00);
        storageRecord.setPayStatus(2);
        storageRecord.setCreatedUserId(1);
        storageRecord.setCreatedTime(new Date());
        storageRecord.setSupplierId(2);
        int result = storageRecordService.add(storageRecord);
        logger.debug("testAdd:"+result);
    }

    @Test
    public void testDel(){
        ApplicationContext context=new ClassPathXmlApplicationContext("applicationContext.xml");
        StorageRecordService storageRecordService = context.getBean(StorageRecordService.class);
        int id=19;
        int del = storageRecordService.del(id);
        logger.debug("testDel:"+del);
    }

    @Test
    public void testModify() {
        ApplicationContext context=new ClassPathXmlApplicationContext("applicationContext.xml");
        StorageRecordService storageRecordService = context.getBean(StorageRecordService.class);
        int id=19;
        String srCode="sr_2019_022";
        String goodsName="雪碧1";
        String goodsDesc="饮料";
        String goodsUnit="瓶";
        double goodsCount=1400.00;
        double totalAmount=4500.00;
        int payStatus=2;
        int updatedUserId=1;
        int supplierId=2;
        StorageRecord storageRecord=new StorageRecord();
        storageRecord.setId(id);
        storageRecord.setSrCode(srCode);
        storageRecord.setGoodsName(goodsName);
        storageRecord.setGoodsDesc(goodsDesc);
        storageRecord.setGoodsUnit(goodsUnit);
        storageRecord.setGoodsCount(goodsCount);
        storageRecord.setTotalAmount(totalAmount);
        storageRecord.setPayStatus(payStatus);
        storageRecord.setUpdatedUserId(updatedUserId);
        storageRecord.setUpdatedTime(new Date());
        storageRecord.setSupplierId(supplierId);
        int result = storageRecordService.modify(storageRecord);
        logger.debug("testModify:"+result);
    }
}